/**
 * 剑指 Offer 53 - II. 0～n-1中缺失的数字
 * https://leetcode-cn.com/problems/que-shi-de-shu-zi-lcof/
 */

/**
 * @param {number[]} nums
 * @return {number}
 */
function missingNumber(nums) {
  const last = nums.length;
  for (let i = 0; i <= last; i += 1) {
    if (nums[i] !== i) {
      return i;
    }
  }
  return 0;
}

console.log(missingNumber([0, 1, 3]) === 2);
console.log(missingNumber([0, 1, 2, 3, 4, 5, 6, 7, 9]) === 8);
